/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once

#include "../节点.h"

#include <字符串转换.h>
#include <core/空间划分/球形八叉树.h>





class C_行文本插座 : public C_插座基类 {
	std::string		m_文本;
public:
	C_行文本插座(std::u16string name);
	~C_行文本插座();

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);

	std::u16string	f_getTypeName() { return u"str"; }
};
#define DEF_转换Str插座(socket) dynamic_cast<C_行文本插座*>( (socket) )
#define DEF_Str插座Value(socket, tid)  *((std::string*)socket->f_getData(tid))

#define DEF_创建Str插座_I(name)  f_add插座(new C_行文本插座( (name) ), E_插座方向::e_插座Type_输入);
#define DEF_创建Str插座_O(name)  f_add插座(new C_行文本插座( (name) ), E_插座方向::e_插座Type_输出);




class C_Bool插座 : public C_插座基类 {
	bool m_默认值;
	bool m_转换值;
public:
	C_Bool插座(std::u16string name);
	~C_Bool插座();

	bool* m_Value;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);
	std::string	f_构建变量代码(int32 loc);

	void		f_读取(FILE* f);
	void		f_写入(FILE* f);
	void        f_Copy(const C_插座基类* node);

	std::u16string		f_getTypeName() { return u"Bool"; }

};
#define DEF_Bool插座(socket) dynamic_cast<C_Bool插座*>( (socket) )
#define DEF_Bool插座数据(socket)  *((bool*)( (socket))->f_getData(0) )

#define DEF_创建Bool插座_I(name) f_add插座(new C_Bool插座( (name) ), E_插座方向::e_插座Type_输入);
#define DEF_创建Bool插座_O(name) f_add插座( new C_Bool插座( (name) ), E_插座方向::e_插座Type_输出);



class C_I8插座 : public C_插座基类 {
	int8 m_默认值;
	int8 m_转换值;

public:
	C_I8插座(std::u16string name);
	~C_I8插座();

	int8*		m_Value;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);
	std::string	f_构建变量代码(int32 loc);

	void		f_读取(FILE* f);
	void		f_写入(FILE* f);
	void        f_Copy(const C_插座基类* node);

	std::u16string		f_getTypeName() { return u"I8"; }

};
#define DEF_转换为I8插座(socket) dynamic_cast<C_I8插座*>( (socket) )
#define DEF_I8插座数据(socket)  *((int8*)( DEF_转换为I8插座(socket))->f_getData(0) )

#define DEF_创建I8插座_I(name) f_add插座(new C_I8插座( (name) ), E_插座方向::e_插座Type_输入);
#define DEF_创建I8插座_O(name) f_add插座( new C_I8插座( (name) ), E_插座方向::e_插座Type_输出);





class C_F32插座 : public C_插座基类 {
public:
	C_F32插座(std::u16string name, float32* mapVal = nullptr);
	~C_F32插座();

	float32*	m_Value;

	void*		f_getData(uint8 线程ID);
	bool		f_getBool(const uvec4& id);
	void		f_setData(void* data, uint8 线程ID = 0);
	void		f_绑定指针(void* data);
	E_JIT_FunParam	f_getJIT参数(uint8 线程ID, uint16 in_ID);
	std::string		f_构建变量代码(int32 loc);
	bool			f_接入插座是否匹配(E_值类型 type);

	void		f_读取(FILE* f);
	void		f_写入(FILE* f);
	void        f_Copy(const C_插座基类* node);

	void		f_upGPU块(uint8 线程ID, bool 更新 = false);

	std::u16string		f_getTypeName() { return u"F32"; }
private:

};

#define DEF_转换为F32插座(socket) dynamic_cast<C_F32插座*>( (socket) )
#define DEF_F32插座数据(socket)  ( *(float32*)((socket)->f_getData(0)) )

#define DEF_创建F32插座_v1_I(name)  f_add插座(new C_F32插座( (name) ), E_插座方向::e_插座Type_输入);
#define DEF_创建F32插座_v1_O(name)  f_add插座(new C_F32插座( (name) ), E_插座方向::e_插座Type_输出);

#define DEF_创建F32插座_I(name, mapVal)  f_add插座(new C_F32插座( (name), (mapVal) ), E_插座方向::e_插座Type_输入);
#define DEF_创建F32插座_O(name, mapVal)  f_add插座(new C_F32插座( (name), (mapVal) ), E_插座方向::e_插座Type_输出);






class C_F64插座 : public C_插座基类 {
public:
	C_F64插座(std::u16string name, float64* mapVal = nullptr);
	~C_F64插座();

	float64* m_Value;

	void* f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);
	void		f_绑定指针(void* data);
	bool		f_接入插座是否匹配(E_值类型 type);

	void		f_读取(FILE* f);
	void		f_写入(FILE* f);

	std::u16string		f_getTypeName() { return u"F64"; }
private:

};

#define DEF_F64插座(socket) dynamic_cast<C_F32插座*>( (socket) )
#define DEF_F64插座数据(socket)  ((float32*)((socket)->f_getData(0)) )

#define DEF_创建F64插座_I(name, mapVal)  socket = new C_F32插座( (name), (mapVal) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建F64插座_O(name, mapVal)  socket = new C_F32插座( (name), (mapVal) ); f_add插座(socket, E_插座方向::e_插座Type_输出);













class C_I32插座 : public C_插座基类 {
	int32 m_默认值;
	int32 m_转换值;
public:
	C_I32插座(std::u16string name, int32* mapVal = nullptr);
	~C_I32插座();

	int32*		m_Value;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);
	std::string	f_构建变量代码(int32 loc);
	bool		f_接入插座是否匹配(E_值类型 type);

	void		f_upGPU块(uint8 线程ID, bool 更新 = false);

	void		f_读取(FILE* f);
	void		f_写入(FILE* f);
	void        f_Copy(const C_插座基类* node);

	std::u16string f_getTypeName() { return u"I32"; }
	void		f_绑定指针(void* data);

private:

};
#define DEF_转换为I32插座(socket) dynamic_cast<C_I32插座*>( (socket) )
#define DEF_I32插座数据(socket)  (*(int32*)socket->f_getData(0))

#define DEF_创建I32插座_I(name)  f_add插座(new C_I32插座( (name) ), E_插座方向::e_插座Type_输入);
#define DEF_创建I32插座_O(name)  f_add插座(new C_I32插座( (name) ), E_插座方向::e_插座Type_输出);







class C_UI32插座 : public C_插座基类 {
	uint32 m_默认值;
	uint32 m_转换值;
public:
	C_UI32插座(std::u16string name, uint32* mapVal = nullptr);
	~C_UI32插座();

	uint32*		m_Value;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);
	std::string	f_构建变量代码(int32 loc);
	void		f_绑定指针(void* data);
	bool		f_接入插座是否匹配(E_值类型 type);

	void		f_读取(FILE* f);
	void		f_写入(FILE* f);
	void        f_Copy(const C_插座基类* node);
	void		f_upGPU块(uint8 线程ID, bool 更新 = false);

	std::u16string		f_getTypeName() { return u"UI32"; }
};
#define DEF_转换为UI32插座(socket) dynamic_cast<C_UI32插座*>( (socket) )
#define DEF_UI32插座数据(socket)  ( *(uint32*)((socket)->f_getData(0)) )

#define DEF_创建UI32插座_I(name) f_add插座(new C_UI32插座( (name) ), E_插座方向::e_插座Type_输入);
#define DEF_创建UI32插座_O(name) f_add插座(new C_UI32插座( (name) ), E_插座方向::e_插座Type_输出);

#define DEF_32I1Dp_CP_32I1Dp(t, s) *((vector<uint32>*)(t)) = *((vector<uint32>*)s)




class C_UI64插座 : public C_插座基类 {
	uint64 m_默认值;
public:
	C_UI64插座(std::u16string name);
	~C_UI64插座();

	uint64		m_Value;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);
	E_JIT_FunParam	f_getJIT参数(uint8 线程ID, uint16 in_ID);
	std::string	f_构建变量代码(int32 loc);
	bool		f_接入插座是否匹配(E_值类型 type);

	void		f_读取(FILE* f);
	void		f_写入(FILE* f);

	std::u16string		f_getTypeName() { return u"UI64"; }
};
#define DEF_转换为UI64插座(socket) dynamic_cast<C_UI64插座*>( (socket) )
#define DEF_UI64插座Value(socket, tid)  *( (uint64*)((socket)->f_getData(tid)) )

#define DEF_创建UI64插座_I(name)  socket = new C_UI64插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建UI64插座_O(name)  socket = new C_UI64插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);




class C_点距八叉树插座 : public C_插座基类 {
public:
	C_点距八叉树插座(std::u16string name);
	~C_点距八叉树插座();

	S_点距八叉树* m_Value;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, uint8 线程ID = 0);
	
	std::u16string		f_getTypeName() { return u"tree"; }
};
#define DEF_转换为点距八叉树插座(socket) dynamic_cast<C_点距八叉树插座*>( (socket) )
#define DEF_点距八叉树插座Value(socket, tid)  ( (S_点距八叉树*)((socket)->f_getData(tid)) )

#define DEF_创建点距八叉树插座_I(name)  socket = new C_点距八叉树插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建点距八叉树插座_O(name)  socket = new C_点距八叉树插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);




class C_体素插座 : public C_插座基类 {
public:
	C_体素插座(std::u16string name);
	~C_体素插座();

	S_体素* m_Value;

	void*	f_getData(uint8 线程ID);
	void	f_setData(void* data, uint8 线程ID = 0);

	std::u16string		f_getTypeName() { return u"vo"; }
};
#define DEF_体素插座(socket) dynamic_cast<C_体素插座*>( (socket) )
#define DEF_体素插座数据(socket)  ( (S_体素*)((socket)->f_getData(0)) )

#define DEF_创建体素插座_I(name)  socket = new C_体素插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建体素插座_O(name)  socket = new C_体素插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);




class C_2D曲线采样值插座 : public C_插座基类 {
public:
	C_2D曲线采样值插座(std::u16string name);
	~C_2D曲线采样值插座();

	S_2D曲线数值*	m_Value;

	void*	f_getData(uint8 线程ID);
	void	f_setData(void* data, uint8 线程ID = 0);
	//void		f_读取(FILE* f);
	//void		f_写入(FILE* f);
	std::u16string		f_getTypeName() { return u"曲线采样值"; }
};
#define DEF_曲线采样值插座(socket) dynamic_cast<C_2D曲线采样值插座*>( (socket) )
#define DEF_曲线采样值插座数据(socket, tid)  ( (S_2D曲线数值*)((socket)->f_getData(tid)) )

#define DEF_创建曲线采样值_1D插座_I(name)  socket = new C_2D曲线采样值插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建曲线采样值_1D插座_O(name)  socket = new C_2D曲线采样值插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);




